import java.util.Arrays;

/**
 * @author tmh
 * @date 2024/9/13 22:53
 * @description
 */
public class T452用最少数量的箭引爆气球 {
    public int findMinArrowShots(int[][] points) {
        //表示至少需要一只键来引爆气球
        int count = 1;
        Arrays.sort(points, (a, b) -> Integer.compare(a[0], b[0]));
        for (int i = 1; i < points.length; i++) {
            if (points[i][0] > points[i - 1][1]) {
                count++;
            } else {
                //更新区间，以最小区间为准
                points[i][1] = Math.min(points[i][1], points[i - 1][1]);
            }
        }
        return count;
    }
}
